package com.golf.server.selection;

import java.io.Serializable;

/**
 * 
 * 
 * @author gfloodgate
 */
public class User implements Serializable
{

	/** <code>serialVersionUID</code> for this class. */
	private static final long serialVersionUID = 6671655248638664192L;
	
	
	/** The user name. */
	private final String name;
	
	
	/**
	 * Create a user with the given name.
	 * 
	 * @param name The user name.
	 * 
	 * @throws IllegalArgumentException If there the user name specified is null.
	 */
	public User(final String name) throws IllegalArgumentException
	{
		if (name == null)
		{
			throw new IllegalArgumentException("User anme cannot be null.");
		}
		
		this.name = name;
	}
	
	
	/**
	 * Get the user name.
	 * 
	 * @return The name of this user.
	 */
	public String getName()
	{
		return name;
	}


	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean equals(final Object obj)
	{
		if (obj instanceof User)
		{
			final User that = (User)obj;
			if (this.name.equals(that.getName()))
			{
				return true;
			}
		}
		
		return false;
	}


	/**
	 * {@inheritDoc}
	 */
	@Override
	public int hashCode()
	{
		return name.hashCode();
	}
	
}
